package org.jeecg.modules.cshApp.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cshApp.entity.CshCitiesEntity;
import org.jeecg.modules.cshApp.entity.CshProvincesEntity;
import org.jeecg.modules.cshApp.service.ICshAdressService;
import org.jeecg.modules.cshApp.vo.CshAdressModule;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 地址管理
 * @Author: 许泽平
 * @Date:   2020-04-01
 * @Version: V1.0
 */
@RestController
@RequestMapping("/csh/cshAdress")
@Slf4j
@Api(tags="地址管理")
public class CshAdressController {

    @Resource
    private ICshAdressService cshAdressService;

    /**
     * 获取所有省份信息
     *
     * @return 返回所有省份信息
     */
    @ApiOperation("获取所有省市区")
    @RequestMapping(value = "/list", method =  RequestMethod.GET)
    public Result<?> findAllProAndCityAndArea(){
        List<CshAdressModule> allProAndCityAndArea = cshAdressService.findAllProAndCityAndArea();
        return Result.ok(allProAndCityAndArea);
    }

    /**
     * 获取福建省市辖区
     *
     * @return 返回福建省市辖区
     */
    @ApiOperation("获取厦门省市区")
    @RequestMapping(value = "/fjList", method =  RequestMethod.GET)
    public Result<?> findXmCity(){
        CshAdressModule fjAreas = cshAdressService.findFjAreas("350000");
        return Result.ok(fjAreas);
    }

    /**
     * 获取开通城市
     *
     * @return 返回开通城市
     */
    @ApiOperation("开通城市")
    @RequestMapping(value = "/openCities", method =  RequestMethod.GET)
    public Result<?> openCities(){
        List<CshCitiesEntity> openCities = cshAdressService.findByOpenCity();
        return Result.ok(openCities);
    }

}
